import defaultPen from './pens/defaultPen.js'
import linePen from './pens/linePen.js'
import ellipsePen from './pens/ellipsePen.js'
import textPen from './pens/textPen.js'
var map = {
    defaultPen: defaultPen,
    linePen: linePen,
    ellipsePen: ellipsePen,
    textPen: textPen,
}
var arr = [
    defaultPen,
    linePen,
    ellipsePen,
    textPen,
]
function getPen(pen) {
    if (typeof pen == "string") {
        return map[pen] || map["defaultPen"]
    }
    if (typeof pen == "number") {
        if (pen < 0 || pen >= arr.length) return arr[0]
        return arr[pen]
    }
    if (typeof pen == "object")
        pen = object.constuctor
    if (typeof pen == "function" && typeof pen.render == "function") {
        var i = arr.indexOf(pen)
        if (i < 0) arr.push(pen)
        return pen
    }
}
var api = function(pen) {
    pen = getPen(pen)
    return pen && pen.default || pen
}

api.key = function(pen) {
    return arr.indexOf(api(pen))
}

export default api
